package com.v2future.sjt.collegecheckingattendance.utils;

import android.util.Log;

import com.library.KLog;


/**
 * log输出工具
 */
public class LogUtils {
	/** The DEBUG TAG. */
	public static final String TAG = LogUtils.class.getSimpleName();

	private static Object lock = new Object();

	/**
	 * Instantiates a new log utils.
	 */
	private LogUtils() {
		super();
	}

	public static void d(String tag, Object... objects) {

		if (Constants.isShowLog) {

			if (objects != null) {

				Log.d(tag, concatStr(objects));
				// for (int i = 0; i < objects.length; i++) {
				// KLog.json(TAG, objects[i].toString());
				// }
			}

		}
	}

	private static String concatStr(Object[] objects) {

		StringBuilder sb = new StringBuilder("");
		if (objects != null) {
			for (int i = 0; i < objects.length; i++) {
				sb.append(objects[i]);
			}
		}

		return sb.toString();

	}

	/**
	 * 打印LOG, 默认使用LogUtils作为标记
	 * 
	 * @param objects
	 *            输出信息
	 */
	public static void d(Object... objects) {
		if (Constants.isShowLog) {
			Log.d(TAG, concatStr(objects));
		}
	}

	/**
	 * 打印log， 格式json
	 * 
	 * @author perfect-sjt
	 * @param tag
	 *            标签
	 * @param jsonStr
	 *            json数据内容
	 * @param heads
	 *            数据头
	 */
	public static void dJson(String tag, Object jsonStr, Object... heads) {
		if (Constants.isShowLog) {
			synchronized (lock) {
				Log.d(tag, "██████████████████" + concatStr(heads)
						+ "████████████████████");
				KLog.json(tag, jsonStr.toString());
				Log.d(tag,
						"------\\(˙<>˙)/------ よろしくお願いします ------\\(˙<>˙)/------");
			}

		}
	}
}
